|
|
|
|
|
|
|
Putting the Resources into the File |
|
|
|
|
|
|
|
|
The most common resources used in an application are stringtable, bitmap, and icon. Creating a file with these resources should be enough to show you how to create a good resource definition file. To create the file, you can use whichever text editor you are most comfortable with; for this section, however, the NotePad editor will be used. |
|
|
|
|
|
|
|
|
The first set of statements in the file will define values that will be used later in the file. Enter the following code into the text editor: |
|
|
|
|
|
|
|
|
#define Str_GetName 1
#define Str_GetBirthdate 2
#define Str_DateError 3
#define Str_ExitMessage 4
#define NewIcon 5
#define Open 6 |
|
|
|
|
|
|
|
|
This code defines several variables to be used with the following command statements, allowing you to change the ID references without having to search the entire file for each occurrence. |
|
|
|
|
|
|
|
|
The next step is to add the stringtable, which contains the string statements your application will use. In this example, four strings will be created in this file. The first two will be used as labels in the application; the second two will be used as messages for the MessageBox statement. Add this code next in the editor to set these strings: |
|
|
|
|
|
|
|
|
STRINGTABLE DISCARDABLE
BEGIN
Str_GetName, Please Enter Your Name:
Str_GetBirthdate, Enter Your Birthdate (mm/dd/yy)
Str_DateError, The date you entered is invalid.
Str_ExitMessage, Okay to Quit?
END |
|
|
|
|
|
|
|
|
The DISCARDABLE option specifies that the resource can be removed from memory if it's no longer being used. |
|
|
|
|
|
|
|
|
Adding an icon and bitmap resource requires that the following statements be added to the resource definition file: |
|
|
|
|
|
|
|
|
NewIcon ICON C:\Temp\Point04.ico
Open BITMAP C:\Temp\Calendar.bmp |
|
|
|
|
|
|
|
|
Include this code in the definition file, using whatever icon and bitmap that you want and have available on your computer. |
|
|
|
|
|